
package org.pubflex.tests{
    import flash.events.*;
    import flash.net.*;
    
    import flexunit.framework.*;
    
    import org.pubflex.SocketURLLoader;
    
    public class HTTPMethodTest extends TestCase    {
        public function HTTPMethodTest( methodName:String ) {
   			super( methodName );
        }
        
        public static function suite():TestSuite {
   			var ts:TestSuite = new TestSuite();
        	ts.addTest( new HTTPMethodTest( "testDelete" ) );
   			return ts;
   		}
   		
   		public function testDelete():void{   		 
            var testURL:String = "http://localhost:8080/server//meta/F72AD3439603F7EC84118623907103124/F72AD3439603F7EC84118623907096815/edit";
            //fail("not working");
           

       	   var loader:SocketURLLoader = new SocketURLLoader();
           var request:URLRequest = new URLRequest();
            request.url = testURL
            //var authHeader:URLRequestHeader = new URLRequestHeader("Authorization","Basic " + your_credentials);
            //request.requestHeaders.push(authHeader);
            //Security.loadPolicyFile('"http://yourhost.com/crossdomain.xml');
            loader.showBusyCursor = true;
            loader.requestTimeout = 6;
            loader.method = "DELETE"

            loader.addEventListener(Event.COMPLETE, traceEvent);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, handleStatusEvent);
			loader.addEventListener(IOErrorEvent.IO_ERROR, traceEvent);
			//loader.addEventListener(ProgressEvent.PROGRESS, traceEvent);
			loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, traceEvent);
   		    		 
   		    var asyncCall:Function = addAsync(traceEvent, 4000);
            loader.load(request);

   		}   		

     private function handleStatusEvent(event:HTTPStatusEvent, token:Object=null):void {
            trace("Event Status : " + event.status);  
            var status:int = event.status; 
            assertEquals("410",status);
              
            trace(event.responseHeaders);            
        }  	
    
     private function traceEvent(event:Event, token:Object=null):void {
            trace(event);    
            trace(event.type);            
        }  		  		
    }
}